#include "PrecompiledHeader.h"
#include "IFrustumTester.h"

/*--------------------------------------------------------------------------*/

IFrustumTester::IFrustumTester()
{
	this->m_frustumTestResult = false;
	this->m_frustumTestEnabled = true;
	this->m_radius = 1.0f;
}

/*--------------------------------------------------------------------------*/

IFrustumTester::~IFrustumTester()
{

}

/*--------------------------------------------------------------------------*/

void IFrustumTester::DoFrustumTest(const glm::vec3& pos, ICamera* camera, bool isCubic)
{
	if (camera != NULL && this->m_frustumTestEnabled)
	{
		if (isCubic)
		{
			this->m_frustumTestResult = camera->IsVisible(pos + (0.5f * glm::vec3(this->m_radius, this->m_radius, this->m_radius)), this->m_radius); ///sqrt2 / 2
		}
		else
		{
			this->m_frustumTestResult = camera->IsVisible(pos, this->m_radius);
		}
	}
}

/*--------------------------------------------------------------------------*/

bool IFrustumTester::GetFrustumTestResult() const
{
	return this->m_frustumTestEnabled == false || (this->m_frustumTestEnabled && this->m_frustumTestResult);
}

/*--------------------------------------------------------------------------*/

void IFrustumTester::SetFrustumTestEnabled(bool b)
{
	this->m_frustumTestEnabled = b;
}

/*--------------------------------------------------------------------------*/

bool IFrustumTester::GetFrustumTestEnabled() const
{
	return this->m_frustumTestEnabled;
}

/*--------------------------------------------------------------------------*/

float IFrustumTester::GetRadius() const
{
	return this->m_radius;
}

/*--------------------------------------------------------------------------*/

void IFrustumTester::SetRadius(float nradius)
{
	this->m_radius = nradius;
}

/*--------------------------------------------------------------------------*/
